import cv2

# 图像的基本变换
# 图像的放大与缩小

cat = cv2.imread('./images/cat.jpg')
dog = cv2.imread('./images/dog.jpg')
new_cat = cv2.resize(cat, (dog.shape[:-1][::-1]))

# 插值算法 默认 INTER_LINEAR
# new_dog1 = cv2.resize(dog, (200, 200), interpolation=cv2.INTER_NEAREST) #邻近插值，速度快，效果差
# new_dog2 = cv2.resize(dog, (200, 200), interpolation=cv2.INTER_LINEAR) #双线性插值，使用原图中的4个点进行插值，默认
# new_dog3 = cv2.resize(dog, (200, 200), interpolation=cv2.INTER_CUBIC) #三次插值，原图中的16个点
# new_dog4 = cv2.resize(dog, (200, 200), interpolation=cv2.INTER_AREA) #区域插值，效果最好，计算时间最长
#
# cv2.imshow('SOURCE', dog)
# cv2.imshow('INTER_NEAREST', new_dog1)
# cv2.imshow('INTER_LINEAR', new_dog2)
# cv2.imshow('INTER_CUBIC', new_dog3)
# cv2.imshow('INTER_AREA', new_dog4)
# 按照x,y轴的比例进行缩放
new_dog = cv2.resize(dog, dsize=None, fx=0.5, fy=0.5)
cv2.imshow('dog', dog)
cv2.imshow('new_dog', new_dog)

cv2.waitKey(0)
cv2.destroyAllWindows()
